package cn.com.thingo.shyintelligent.model;

import android.content.SharedPreferences;

import cn.com.thingo.shyintelligent.model.bean.CommonBean;
import cn.com.thingo.shyintelligent.model.bean.GatewayListBean;
import cn.com.thingo.shyintelligent.model.bean.LoginBean;
import cn.com.thingo.shyintelligent.model.bean.MessageListBean;
import cn.com.thingo.shyintelligent.model.bean.UserBean;
import cn.com.thingo.shyintelligent.model.http.HttpHelper;
import cn.com.thingo.shyintelligent.model.prefs.PreferencesHelper;
import io.reactivex.Flowable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;

/**
 * Created by Administrator on 2017/10/9.
 */

public class DataManager implements HttpHelper, PreferencesHelper {

    private HttpHelper mHttpHelper;
    private PreferencesHelper mPreferencesHelper;

    public DataManager(HttpHelper httpHelper, PreferencesHelper preferencesHelper) {
        mHttpHelper = httpHelper;
        mPreferencesHelper = preferencesHelper;
    }

    @Override
    public String getUserName() {
        return mPreferencesHelper.getUserName();
    }

    @Override
    public void setUserNameAndPwd(String userName, String pwd) {
        mPreferencesHelper.setUserNameAndPwd(userName, pwd);
    }

    @Override
    public String getPwd() {
        return mPreferencesHelper.getPwd();
    }


    @Override
    public SharedPreferences getSPrefs() {
        return mPreferencesHelper.getSPrefs();
    }

    @Override
    public boolean getLoginState() {
        return mPreferencesHelper.getLoginState();
    }

    @Override
    public void setLoginState(boolean state) {
        mPreferencesHelper.setLoginState(state);
    }

    @Override
    public boolean getRememberPW() {
        return mPreferencesHelper.getRememberPW();
    }

    @Override
    public void setRememberPW(boolean state) {
        mPreferencesHelper.setRememberPW(state);
    }

    @Override
    public boolean getNightModeState() {
        return mPreferencesHelper.getNightModeState();
    }

    @Override
    public void setNightModeState(boolean state) {
        mPreferencesHelper.setNightModeState(state);
    }

    @Override
    public boolean getNoImageState() {
        return mPreferencesHelper.getNoImageState();
    }

    @Override
    public void setNoImageState(boolean state) {
        mPreferencesHelper.setNoImageState(state);
    }

    @Override
    public boolean getAutoCacheState() {
        return mPreferencesHelper.getAutoCacheState();
    }

    @Override
    public void setAutoCacheState(boolean state) {
        mPreferencesHelper.setAutoCacheState(state);
    }

    @Override
    public int getCurrentItem() {
        return mPreferencesHelper.getCurrentItem();
    }

    @Override
    public void setCurrentItem(int item) {
        mPreferencesHelper.setCurrentItem(item);
    }

    @Override
    public boolean getLikePoint() {
        return mPreferencesHelper.getLikePoint();
    }

    @Override
    public void setLikePoint(boolean isFirst) {
        mPreferencesHelper.setLikePoint(isFirst);
    }

    @Override
    public boolean getVersionPoint() {
        return mPreferencesHelper.getVersionPoint();
    }

    @Override
    public void setVersionPoint(boolean isFirst) {
        mPreferencesHelper.setVersionPoint(isFirst);
    }

    @Override
    public boolean getManagerPoint() {
        return mPreferencesHelper.getManagerPoint();
    }

    @Override
    public void setManagerPoint(boolean isFirst) {
        mPreferencesHelper.setManagerPoint(isFirst);
    }

    //获取手机验证码
    @Override
    public Flowable<CommonBean> getCode(String telephone) {
        return mHttpHelper.getCode(telephone);
    }

    @Override
    public Flowable<CommonBean> register(String code, String password, String telephone) {
        return mHttpHelper.register(code, password, telephone);
    }

    @Override
    public Flowable<LoginBean> login(String password, String telephone) {
        return mHttpHelper.login(password, telephone);
    }

    @Override
    public Flowable<GatewayListBean> gatewayList(String token) {
        return mHttpHelper.gatewayList(token);
    }

    @Override
    public Flowable<CommonBean> addGateway(String username, String password, String number, String title, String token) {
        return mHttpHelper.addGateway(username, password, number, title, token);
    }

    @Override
    public Flowable<UserBean> getUser(String token) {
        return mHttpHelper.getUser(token);
    }

    @Override
    public Flowable<CommonBean> modifyHead(RequestBody token, MultipartBody.Part headPic) {
        return mHttpHelper.modifyHead(token, headPic);
    }

    @Override
    public Flowable<CommonBean> modifyPassword(String password, String telephone, String code) {
        return mHttpHelper.modifyPassword(password, telephone, code);
    }

    @Override
    public Flowable<CommonBean> addMessage(String token, String title, String content) {
        return mHttpHelper.addMessage(token, title, content);
    }

    @Override
    public Flowable<MessageListBean> messageList(String token) {
        return mHttpHelper.messageList(token);
    }

    @Override
    public Flowable<CommonBean> messageCount(String token) {
        return mHttpHelper.messageCount(token);
    }

    @Override
    public Flowable<CommonBean> readMessage(String token, String messageId) {
        return mHttpHelper.readMessage(token, messageId);
    }


}
